/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __CameraObject_H__
#define __CameraObject_H__

#include "GameObject.h"

namespace PQClient
{
	class CameraObject
		: public GameObject
	{
	public:
		CameraObject(SceneObject* scene);

		void resetViewport();

		inline void setPolygonMode(Ogre::PolygonMode mode)
		{
			_camera->setPolygonMode(mode);
		}

		inline void setBackgroundColour(Ogre::ColourValue color)
		{
			_camera->getViewport()->setBackgroundColour(color);
		}

		inline void setAspectRatio(float width,float height)
		{
			float ratio=width/height;
			_camera->setAspectRatio(width/height);
		}

		inline void setFarClipDistance(float distance)
		{
			_camera->setFarClipDistance(distance);
		}

		inline void setNearClipDistance(float distance)
		{
			_camera->setNearClipDistance(distance);
		}

		inline float getFarClipDistance()
		{
			return _camera->getFarClipDistance();
		}

		inline float getNearClipDistance()
		{
			return _camera->getNearClipDistance();
		}


		inline Ogre::Ray getRay(int x,int y)
		{
			int width=_camera->getViewport()->getActualWidth();
			int height=_camera->getViewport()->getActualHeight();

			Ogre::Ray mouseRay = _camera->getCameraToViewportRay((float)x/(float)width,(float)y/(float)height);
			return mouseRay;
		}

		inline void lookAt(float x,float y,float z)
		{
			_sceneNode->lookAt(Ogre::Vector3(x,y,z),Ogre::Node::TS_WORLD);
		}

		inline void lookAt(Ogre::Vector3 vec)
		{
			_sceneNode->lookAt(vec,Ogre::Node::TS_WORLD);
		}


		inline void yaw(Ogre::Degree deg)
		{
			_sceneNode->yaw(deg);

		}

		inline void pitch(Ogre::Degree deg)
		{
			_sceneNode->pitch(deg);
		}

		inline Ogre::Vector3 getDirection()
		{
			return _sceneNode->getOrientation()* -Ogre::Vector3::UNIT_Z;
		}

		inline Ogre::Vector3 getUp()
		{
			return _sceneNode->getOrientation()* Ogre::Vector3::UNIT_Y;
		}

		inline Ogre::Vector3 getRight()
		{
			return _sceneNode->getOrientation()* Ogre::Vector3::UNIT_X;
		}

		inline Ogre::Camera* getCamera()
		{
			return _camera;
		}

		

	private:
		Ogre::Camera* _camera;
		Ogre::Viewport* _viewport;

	};
}
#endif
